package com.intelligent.health.member.feign.fallback;

import com.intelligent.health.member.feign.MemberFeignClient;
import entity.R;
import entity.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: torlesse-liang
 * @Date: 2022/03/20/21:46
 * @Description: MemberFeignClientFallbackFactory
 */
@Slf4j
@Component
public class MemberFeignClientFallbackFactory implements FallbackFactory<MemberFeignClient> {

    @Override
    public MemberFeignClient create(Throwable cause) {
        return new MemberFeignClient() {
            @Override
            public R getUserAndAuthInfo(String username) {
                log.error("获取用户角色权限失败: {}",username);
                return R.setResult(ResultCodeEnum.SERVER_ERROR);
            }
        };
    }
}
